import 'dart:developer';

class GeoBean {
  late String? code;
  late List<Location>? location;
  late Refer? refer;

  GeoBean({this.code, this.location, this.refer});

  GeoBean.fromJson(Map<String, dynamic> json) {

    code = json['code'];
    if (json['location'] != null) {
      location = <Location>[];
      json['location'].forEach((v) {
        location?.add(Location.fromJson(v));
      });
    }
    refer = (json['refer'] != null ? Refer.fromJson(json['refer']) : null)!;
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = Map<String, dynamic>();
    data['code'] = code;
    if (location != null) {
      data['location'] = location?.map((v) => v.toJson()).toList();
    }
    if (refer != null) {
      data['refer'] = refer?.toJson();
    }
    return data;
  }

  @override
  String toString() {
    return 'GeoBean{code: $code, location: $location, refer: $refer}';
  }
}

class Location {
  late String? name;
  late String? id;
  late String? lat;
  late String? lon;
  late String? adm2;
  late String? adm1;
  late String? country;
  late String? tz;
  late String? utcOffset;
  late String? isDst;
  late String? type;
  late String? rank;
  late String? fxLink;

  Location(
      {this.name,
      this.id,
      this.lat,
      this.lon,
      this.adm2,
      this.adm1,
      this.country,
      this.tz,
      this.utcOffset,
      this.isDst,
      this.type,
      this.rank,
      this.fxLink});

  Location.fromJson(Map<String, dynamic> json) {
    name = json['name'];
    id = json['id'];
    lat = json['lat'];
    lon = json['lon'];
    adm2 = json['adm2'];
    adm1 = json['adm1'];
    country = json['country'];
    tz = json['tz'];
    utcOffset = json['utcOffset'];
    isDst = json['isDst'];
    type = json['type'];
    rank = json['rank'];
    fxLink = json['fxLink'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['name'] = this.name;
    data['id'] = this.id;
    data['lat'] = this.lat;
    data['lon'] = this.lon;
    data['adm2'] = this.adm2;
    data['adm1'] = this.adm1;
    data['country'] = this.country;
    data['tz'] = this.tz;
    data['utcOffset'] = this.utcOffset;
    data['isDst'] = this.isDst;
    data['type'] = this.type;
    data['rank'] = this.rank;
    data['fxLink'] = this.fxLink;
    return data;
  }

  @override
  String toString() {
    return 'Location{name: $name, id: $id, lat: $lat, lon: $lon, adm2: $adm2, adm1: $adm1, country: $country, tz: $tz, utcOffset: $utcOffset, isDst: $isDst, type: $type, rank: $rank, fxLink: $fxLink}';
  }
}

class Refer {
  late List<String>? sources;
  late List<String>? license;

  Refer({this.sources, this.license});

  Refer.fromJson(Map<String, dynamic> json) {
    sources = json['sources'].cast<String>();
    license = json['license'].cast<String>();
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['sources'] = this.sources;
    data['license'] = this.license;
    return data;
  }

  @override
  String toString() {
    return 'Refer{sources: $sources, license: $license}';
  }
}
